const request = require('../utils/request')

/**
 * 执行登录
 * @param data
 * @returns {Promise<unknown>}
 */
export const login = (data) => request.post('/api/auth/login', data)

/**
 * 执行注册
 * @param data
 * @returns {Promise<unknown>}
 */
export const register = (data) => request.post('/api/auth/register', data)

/**
 * 发送code, 获取openid, 已经用户信息(已绑定的情况)
 * @param data
 * @returns {Promise<unknown>}
 */
export const getOpenid = (data) => request.post('/api/auth/wx/code', data, false)

/**
 * 对当前登录的账号, 绑定微信 / 或者解绑微信
 * @param data
 * @returns {Promise<unknown>}
 */
export const bindOpenid = (data) => request.post('/api/auth/wx/bind', data)

/**
 * 退出登录
 * @returns {Promise<unknown>}
 */
export const logout = () => request.post('/api/auth/logout')

/**
 * 获取oss上传配置
 * @returns {Promise<unknown>}
 */
export const getOssConfig = () => request.get('/api/auth/oss/token')